using System;
using System.Collections.Generic;
using System.Text;
using Evolution.Engine.GUI.Components;
using Microsoft.Xna.Framework;
using Evolution.Engine.Managers;
using Microsoft.Xna.Framework.Graphics;

namespace Evolution.GUI.Components
{
    public class Lable : Control
    {
        private string _Font;
        private bool _AutoSize;
        private Color _TextColor;

        public Color TextColor { get { return _TextColor; } set { _TextColor = value; } }
        public bool AutoSize { get { return _AutoSize; } set { _AutoSize = value; SetSize(); } }
        public string Font { get { return _Font; } set { _Font = value; } }

        public Lable(Form parent, string Text, Vector2 Position, string Font)
            : base(parent)
        {
            _Text = Text;
            _Location = Position;
            _Font = Font;
            _TextColor = Color.Yellow;
            SetSize();
        }

        private void SetSize()
        {
            if (_AutoSize)
            {
                Vector2 size = FontManager.Instance[Font].MeasureString(_Text);
                _Size = new SizeF(size.X, size.Y);
            }
        }

        public override void Draw(GameTime gameTime)
        {
            TextManager.Instance.Write(
                _Font,
                _Text,
                _Location + _Parent.Location,
                _TextColor
            );
        }
    }
}
